package com.qububu.play.common.dto;

import java.io.Serializable;
import java.util.Arrays;

import com.qububu.utils.SystemUtil;


public class ArticleInfoDto implements Serializable{
	
	private static final long serialVersionUID = 1L;
	private String articleId;
	private String articleTitle;
	private String articleSummaryText;
	private String artSummaryPicUrl;
	private int articleCreateDttm;
	private String articleCreateIp;
	private ArticleType articleType;
	private ArticleAuthor author;
	
	/**
	 *  得到加密的articleId, userId
	 */
	public ArticleInfoDto(String articleId){
		this.articleId = articleId;
	}
	
	/**
	 *  得到未加密的articleId, userId
	 */
	public ArticleInfoDto(long articleId){
		this.articleId = SystemUtil.encrypt(String.valueOf(articleId));
	}
	
	public String getArticleId() {
		return articleId;
	}
	
	public String getArticleTitle() {
		return articleTitle;
	}
	
	public void setArticleTitle(String articleTitle) {
		this.articleTitle = articleTitle;
	}
	
	public String getArticleSummaryText() {
		return articleSummaryText;
	}
	
	public void setArticleSummaryText(String articleSummaryText) {
		this.articleSummaryText = articleSummaryText;
	}
	
	public String getArtSummaryPicUrl() {
		return artSummaryPicUrl;
	}
	
	public void setArtSummaryPicUrl(String artSummaryPicUrl) {
		this.artSummaryPicUrl = artSummaryPicUrl;
	}
	
	public int getArticleCreateDttm() {
		return articleCreateDttm;
	}
	
	public void setArticleCreateDttm(int articleCreateDttm) {
		this.articleCreateDttm = articleCreateDttm;
	}
	
	public String getArticleCreateIp() {
		return articleCreateIp;
	}
	
	public void setArticleCreateIp(String articleCreateIp) {
		this.articleCreateIp = articleCreateIp;
	}
	
	/*public int getArticleType() {
		return articleType;
	}
	
	public void setArticleType(int articleType) {
		this.articleType = articleType;
	}*/

	public ArticleAuthor getAuthor() {
		return author;
	}

	public void setAuthor(ArticleAuthor author) {
		this.author = author;
	}

	public ArticleType getArticleType() {
		return articleType;
	}
	
	public void setArticleType(ArticleType articleType) {
		this.articleType = articleType;
	}


	public enum ArticleType {
		SPORT(0),
		DINE(1),
		BLAST(2),//吐槽
		SHOW(3);
		
		private int intValue;
		
		private ArticleType (int intValue) {
			this.intValue = intValue;
		}
		/**
		 * 返回int值类型。
		 * @return
		 */
		public int toIntValue() {
			return intValue;
		}
		
		
		/**
		 * 根据传入字符串来返回对应的状态类型
		 */
		public static ArticleType getArticleType (String strValue){
			
			try {
				ArticleType type = valueOf(strValue);
				return type;
			} catch (Exception e) {
				throw new IllegalArgumentException("Value '" + strValue + "' is not allowed in ArticleType. Only "
						+ Arrays.toString(ArticleType.values()) + " are allowed."
						);
			}
		}
		
		/**
		 * 根据传入INT值来返回对应的状态类型
		 */
		public static ArticleType getArticleType (int intValue){
			
			for (ArticleType elem : ArticleType.values()) {
				if (elem.toIntValue() == intValue) {
					return elem;
				}
			}
			throw new IllegalArgumentException("Value '" + intValue
					+ "' is not allowed in ArticleType.");
		}
		
	}
}